﻿@using IEMSOFT.EasyHotel.Common
@using IEMSOFT.EasyHotel.Admin.Models
@using IEMSOFT.Foundation
@model List<IEMSOFT.EasyHotel.Admin.Models.RoomStatusModel>
@{
    ViewBag.Title = "房间状态";
}
@section header
{
    <style type="text/css">
        .room {
            height: 57px;
            width: 100px;
            position: absolute;
            left: 0px;
            top: 0px;
            position: absolute;
            cursor: pointer;
        }

            .room span {
                left: 10px;
                top: 10px;
                position: absolute;
            }

            .room #span2 {
                left: 10px;
                top: 40px;
                position: absolute;
            }

        .action {
            padding-top: 10px;
        }

            .action button {
                width: 100px;
                height: 30px;
                border-radius: 5px;
                background-color: #ff6a00;
                font-size: 14px;
                font-weight: bold;
            }

        .greyBack {
            background-color: grey;
        }
    </style>
}
@{
    var currentUser = ViewBag.CurrentUser as UserModel;
}
@if (currentUser.RoleId == RoleType.GroupLeader.ToInt())
{
    <form id="fmSearchCheckinStatus">
        <div class="fitem">
            <label>所在分店:</label>
            <select class="easyui-combobox" name="subHotelId" id="cbSubHotelId_SearchCheckinStatus"
                    data-options="url:'/subhotel/option?defaultText=%E8%AF%B7%E9%80%89%E6%8B%A9&defaultValue=0',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="searchCheckinStatus()" style="width: 90px">查询</a>
    </form>
}
else
{
    <div class="action">
        <button onclick="checkIn()" class="easyui-linkbutton c6">入住</button>
        <button onclick="checkOut()" class="easyui-linkbutton c6">退房</button>
        @if (currentUser.RoleId == RoleType.HotelManager.ToInt())
        {
            <button onclick="reviseCheckin()" class="easyui-linkbutton c6">修改入住</button>
            <button onclick="cancelCheckin()" class="easyui-linkbutton c6">取消入住</button>
        }
        else//前台仅仅有打印权限
        {
            <button onclick="openPrintCheckin()" class="easyui-linkbutton c6">打印入住</button>
        }
        <button onclick="setMending()" class="easyui-linkbutton c6">房间维修</button>
        <button onclick="setNormal()" class="easyui-linkbutton c6">房间可用</button>
    </div>
}

<div id="dlgCheckIn" class="easyui-dialog" style="width: 400px; height: 490px; padding: 10px 20px"
     closed="true" buttons="#dlg-buttonsCheckin">
    <form id="fmCheckIn" method="post" data-options="novalidate:true">
        <input type="hidden" name="billId" />
        <div class="fitem">
            <label>订单号：</label>
            <input name="billNo" class="easyui-textbox" readonly="true" id="txtBillNo_Checkin" />
        </div>
        <div class="fitem">
            <label>入住时间：</label>
            <input name="checkinDate" class="easyui-textbox" readonly="true" id="txtCheckinDate_Checkin" />
        </div>
        <div class="fitem">
            <label>房间：</label>
            <select id="cbRoomId_CheckIn" class="easyui-combobox" name="roomId"
                    data-options="method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem">
            <label>姓名：</label>
            <input name="customerName" class="easyui-textbox" required="true" />
        </div>
        <div class="fitem">
            <label>身份证：</label>
            <input name="customerIDNo" class="easyui-textbox" required="true" />
        </div>
        <div class="fitem">
            <label>支付方式：</label>
            <select class="easyui-combobox" name="payTypeId" id="cbPayTypeId_CheckIn"
                    data-options="url:'/paytype/option',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem">
            <label>旅行社：</label>
            <select class="easyui-combobox" name="travelAgencyId" id="cbTravelAgencyId_CheckIn"
                    data-options="url:'/travelagency/option',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem">
            <label>钟点房：</label>
            <select class="easyui-combobox" name="isHourRoom" id="cbIsHourRoom_CheckIn"
                    data-options="url:'/misc/IsHourRoomOption',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem" id="divDayRoom_Checkin">
            <label>单价：</label>
            <input name="singlePrice" class="easyui-textbox" id="txtSinglePrice_CheckIn" />
        </div>
        <div id="divHourRoom_CheckIn">
            <div class="fitem">
                <label>最低房费：</label>
                <input name="minFeeForHourRoom" class="easyui-textbox" id="txtMinFeeForHourRoom_CheckIn" />
            </div>
            <div class="fitem">
                <label>每小时房费：</label>
                <input name="pricePerHour" class="easyui-textbox" id="txtPricePerHour_CheckIn" />
            </div>
        </div>
        <div class="fitem">
            <label>预付款：</label>
            <input name="deposit" class="easyui-textbox" />
        </div>
        <div class="fitem">
            <label>其他备注：</label>
            <input name="comments" class="easyui-textbox" data-options="multiline:true" style="height: 50px" />
        </div>
    </form>
</div>
<div id="dlg-buttonsCheckin">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-print" onclick="printCheckin()" style="width: 90px">打印</a>
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="save()" style="width: 90px" id="btnCheckinSubmit">提交</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlgCheckIn').dialog('close')" style="width: 90px">取消</a>
</div>

<div id="dlgCheckOut" class="easyui-dialog" style="width: 400px; height: 610px; padding: 10px 20px"
     closed="true" buttons="#dlg-buttonsCheckOut">
    <form id="fmCheckOut" method="post" data-options="novalidate:true">
        <input type="hidden" name="billId" />
        <div class="fitem">
            <label>房间：</label>
            <select id="cbRoomId_CheckOut" class="easyui-combobox" name="roomId"
                    data-options="method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem">
            <label>订单号：</label>
            <input name="billNo" class="easyui-textbox" readonly="true" id="txtBillNo_CheckOut" />
        </div>
        <div class="fitem">
            <label>入住时间：</label>
            <input name="checkinDate" class="easyui-textbox" readonly="true" id="txtCheckinDate_CheckOut" />
        </div>
        <div class="fitem">
            <label>退房时间：</label>
            <input name="checkoutDate" class="easyui-textbox" readonly="true" id="txtCheckoutDate_CheckOut" />
        </div>
        <div class="fitem">
            <label>姓名：</label>
            <input name="customerName" class="easyui-textbox" readonly="true" required="true" />
        </div>
        <div class="fitem">
            <label>身份证：</label>
            <input name="customerIDNo" class="easyui-textbox" readonly="true" required="true" />
        </div>
        <div class="fitem">
            <label>支付方式：</label>
            <select class="easyui-combobox" name="payTypeId" id="cbPayTypeId_CheckOut" readonly="true"
                    data-options="url:'/paytype/option',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem">
            <label>旅行社：</label>
            <select class="easyui-combobox" name="travelAgencyId" id="cbTravelAgencyId_CheckOut" readonly="true"
                    data-options="url:'/travelagency/option',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div class="fitem">
            <label>钟点房：</label>
            <select class="easyui-combobox" name="isHourRoom" id="cbIsHourRoom_CheckOut" readonly="true"
                    data-options="url:'/misc/IsHourRoomOption',method:'get',valueField:'value',textField:'text'"></select>
        </div>
        <div id="divDayRoom_CheckOut">
            <div class="fitem">
                <label>单价：</label>
                <input name="singlePrice" class="easyui-textbox" readonly="true" />
            </div>
            <div class="fitem">
                <label>入住总天数：</label>
                <input name="stayTotalDays" class="easyui-textbox" readonly="true" />
            </div>
        </div>
        <div id="divHourRoom_CheckOut">
            <div class="fitem">
                <label>最低房费：</label>
                <input name="minFeeForHourRoom" class="easyui-textbox" readonly="true" />
            </div>
            <div class="fitem">
                <label>每小时房费：</label>
                <input name="pricePerHour" class="easyui-textbox" readonly="true" />
            </div>
            <div class="fitem">
                <label>入住小时数：</label>
                <input name="stayTotalHours" class="easyui-textbox" readonly="true" />
            </div>
        </div>
        <div class="fitem">
            <label>房费：</label>
            <input name="roomTotalFee" class="easyui-textbox" readonly="true" id="txtroomTotalFee_Checkout" />
        </div>
        <div class="fitem">
            <label>消费金额：</label>
            <input name="consumeFee" class="easyui-textbox" id="txtConsumeFee_Checkout" />
        </div>
        <div class="fitem">
            <label>消费项目：</label>
            <input name="consumeItem" class="easyui-textbox" data-options="multiline:true" style="height: 50px" />
        </div>
        <div class="fitem">
            <label>预付款：</label>
            <input name="deposit" class="easyui-textbox" readonly="true" id="txtDeposit_Checkout" />
        </div>
        <div class="fitem">
            <label>其他备注：</label>
            <input name="comments" class="easyui-textbox" data-options="multiline:true" style="height: 50px" />
        </div>
    </form>
</div>
<div id="dlg-buttonsCheckOut">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="save()" style="width: 90px">退房</a>
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-print" onclick="printCheckout()" style="width: 90px">打印</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlgCheckOut').dialog('close')" style="width: 90px">取消</a>
</div>

<div id="dlgMending" class="easyui-dialog" style="width: 400px; height: 160px; padding: 10px 20px"
     closed="true" buttons="#dlg-buttonsMending">
    <form id="fmMending" method="post" data-options="novalidate:true">
        <input type="hidden" name="billId" />
        <div class="fitem">
            <label>房间：</label>
            <select id="cbRoomId_Mending" class="easyui-combobox" name="roomId"
                    data-options="method:'get',valueField:'value',textField:'text'"></select>
        </div>
    </form>
</div>
<div id="dlg-buttonsMending">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="save()" style="width: 90px">提交</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlgMending').dialog('close')" style="width: 90px">取消</a>
</div>

@{
    var totalCount = Model.Count;
    var width = 100;
    var height = 57;
    var column = ViewBag.RoomColumnCount;
    var row = 0;
    var index = 0;
    if (totalCount % column == 0)
    {
        row = totalCount / column;
    }
    else
    {
        row = totalCount / column + 1;
    }
    var top = 20;
}
@for (int rowno = 1; rowno <= row; rowno++)
{
    var left = -90;
    top = top + height;
    for (int columnno = 1; columnno <= column; columnno++)
    {
        if (index >= totalCount)
        {
            break;
        }
        var roomStatus = Model[index];
        index++;
        left = left + width;
        var style = string.Format("left: {0}px; top: {1}px;", left, top);
        if (roomStatus.RoomStatusId == RoomStatusType.CheckedIn && roomStatus.IsHourRoom == false)
        {
            <div style="@style" class="room" ondblclick="checkOut(@roomStatus.RoomId)">
                <img src="~/Images/checkedin.png" />
                <span>@(string.Format("{0}{1} {2}", roomStatus.RoomNo, roomStatus.RoomTypeName, roomStatus.RoomStatusName))</span>
            </div>
        }
        else if (roomStatus.RoomStatusId == RoomStatusType.CheckedIn && roomStatus.IsHourRoom)
        {
            <div style="@style" class="room" ondblclick="checkOut(@roomStatus.RoomId)">
                <img src="~/Images/roomHourCheckedin.png" />
                <span>@(string.Format("{0}{1} {2}", roomStatus.RoomNo, roomStatus.RoomTypeName, roomStatus.RoomStatusName))</span>
            </div>
        }
        else if (roomStatus.RoomStatusId == RoomStatusType.IsMending)
        {<div style="@style" class="room" ondblclick="setNormal(@roomStatus.RoomId)">
            <img src="~/Images/ismending.png" />
            <span>@(string.Format("{0}{1} {2}", roomStatus.RoomNo, roomStatus.RoomTypeName, roomStatus.RoomStatusName))</span>
        </div>
        }
        else
        {<div style="@style" class="room" ondblclick="checkIn(@roomStatus.RoomId)">
            <img src="~/Images/normal.png" />
            <span>@(string.Format("{0}{1} {2}", roomStatus.RoomNo, roomStatus.RoomTypeName, roomStatus.RoomStatusName))</span>
        </div>
        }
    }
}

<div id="divCheckinPrint" style="display:none">

</div>
<div id="divCheckoutPrint" style="display:none">

</div>
@section scripts
{
    <script type="text/javascript">
        var actionType = { checkin: 1, checkout: 2, setMending: 3, setNormal: 4, cancelCheckin: 5, reviseCheckin: 6, openPrintCheckin: 7 };
        var action = actionType.checkin;
        var payType = { Cash: 1, pendingPay: 2 };
        var actionUrl = '';
        var msgTitle = '';
        var roleId = '@currentUser.RoleId';
        var subHotelId = '@ViewBag.SubHotelId';

        function toggleCheckinItemsForHourRoom(isHourRoom) {
            if (isHourRoom == '1') {
                $("#divDayRoom_Checkin").hide();
                $("#divHourRoom_CheckIn").show();
            }
            else {
                $("#divDayRoom_Checkin").show();
                $("#divHourRoom_CheckIn").hide();
            }
        }

        function toggleCheckOutItemsForHourRoom(isHourRoom) {
            if (isHourRoom == '1') {
                $("#divDayRoom_CheckOut").hide();
                $("#divHourRoom_CheckOut").show();
            }
            else {
                $("#divDayRoom_CheckOut").show();
                $("#divHourRoom_CheckOut").hide();
            }
        }
        function getPredefinedPrice(roomId) {
            $.get('/roomType/getOne?roomid=' + roomId,
                          function (data) {
                              var msg = '';
                              if (data.msg.length != 0) {
                                  $.each(data.msg, function () {
                                      msg = data.msg + msg + '<br/>';
                                  });
                                  $.messager.alert(msgTitle, msg, 'error');
                              }
                              else {
                                  $('#txtSinglePrice_CheckIn').textbox('setValue', data.data.singlePrice);
                                  $('#txtMinFeeForHourRoom_CheckIn').textbox('setValue', data.data.minFeeForHourRoom);
                                  $('#txtPricePerHour_CheckIn').textbox('setValue', data.data.pricePerHour);
                              }
                          });
        }
        $(function () {
            if (roleId == roleType.groupLeader) {//集团领导点击查询时由于刷新页面，导致选中的值消失，此处是重置
                $('#cbSubHotelId_SearchCheckinStatus').combobox({
                    onLoadSuccess: function () {
                        $('#cbSubHotelId_SearchCheckinStatus').combobox('setValue', subHotelId);
                    }
                });

            }
            $('#cbRoomId_CheckOut').combobox({
                onSelect: function (record) {
                    preSettle(record.value);
                }
            });
            $('#cbIsHourRoom_CheckIn').combobox({
                onSelect: function (record) {
                    toggleCheckinItemsForHourRoom(record.value);
                }
            });

            $('#cbRoomId_CheckIn').combobox({
                onSelect: function (record) {
                    if (action == actionType.reviseCheckin || action == actionType.openPrintCheckin) {
                        $.post('/bill/getOnePendingByRoomId',
                             'roomid=' + record.value,
                             function (data) {
                                 var msg = '';
                                 if (data.msg.length != 0) {
                                     $.each(data.msg, function () {
                                         msg = data.msg + msg + '<br/>';
                                     });
                                     $.messager.alert(msgTitle, msg, 'error');
                                 }
                                 else {
                                     $('#fmCheckIn').form('load', data.data);
                                     toggleCheckinItemsForHourRoom(data.data.isHourRoom);
                                 }
                             });
                    }
                    else if (action == actionType.checkin) {
                        getPredefinedPrice(record.value);
                    }
                }
            });
        });
        function searchCheckinStatus() {
            var subHotelId = $('#cbSubHotelId_SearchCheckinStatus').combobox('getValue');
            location.href = "/room/roomstatus?subHotelId=" + subHotelId;
        }
        function printCheckin() {
            $.post('/room/printCheckin',
                    $('#fmCheckIn').serialize(),
                   function (data) {
                       $('#divCheckinPrint').empty();
                       $('#divCheckinPrint').append(data);
                       $('#divCheckinConfirm').printArea();
                   });
        }
        function printCheckout() {
            $.post('/room/printCheckout',
                    $('#fmCheckOut').serialize(),
                   function (data) {
                       $('#divCheckoutPrint').empty();
                       $('#divCheckoutPrint').append(data);
                       $('#divCheckoutConfirm').printArea();
                   });
        }
        function preSettle(roomId) {
            $.post('/bill/presettle',
                      'roomid=' + roomId,
                      function (data) {
                          var msg = '';
                          if (data.msg.length != 0) {
                              $.each(data.msg, function () {
                                  msg = data.msg + msg + '<br/>';
                              });
                              $.messager.alert(msgTitle, msg, 'error');
                          }
                          else {
                              $('#fmCheckOut').form('load', data.data);
                              toggleCheckOutItemsForHourRoom(data.data.isHourRoom);
                          }
                      }); 
        }
        function checkIn(roomId) {
            msgTitle = "入住";
            action = actionType.checkin;
            toggleCheckinItemsForHourRoom('0');
            $('#dlgCheckIn').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_CheckIn').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.Normal);
            $('#fmCheckIn').form('clear');
            $('#fmCheckIn input[name=roomId]').prev().focus();//设置焦点
            $('#cbRoomId_CheckIn').combobox('setValue', '');
            $('#cbTravelAgencyId_CheckIn').combobox('setValue', '0');
            $('#txtCheckinDate_Checkin').textbox('setValue', new Date().Format("yyyy-MM-dd hh:mm:ss"));
            $('#txtBillNo_Checkin').textbox('setValue', new Date().Format("yyyyMMddhhmmssS"));
            $('#cbPayTypeId_CheckIn').combobox('setValue', payType.Cash);
            actionUrl = "/bill/create";
            $('#cbIsHourRoom_CheckIn').combobox('setValue', '0');
            if (roomId != undefined) {
                $('#cbRoomId_CheckIn').combobox('setValue', roomId);
                getPredefinedPrice(roomId);
            }
            $('#btnCheckinSubmit').linkbutton('enable');
        }
        function checkOut(roomId) {
            msgTitle = "退房";
            action = actionType.checkout;
            actionUrl = "/bill/settle";
            $('#dlgCheckOut').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_CheckOut').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.CheckedIn);
            $('#fmCheckOut').form('clear');
            $('#cbRoomId_CheckOut').combobox('setValue', '');
            $('#fmCheckOut input[name=roomId]').prev().focus();//设置焦点
            if (roomId != undefined) {
                $('#cbRoomId_CheckOut').combobox('setValue', roomId);
                preSettle(roomId);
            }
        }
        function setMending() {
            msgTitle = "房间维修";
            action = actionType.setMending;
            actionUrl = "/room/setMending";
            $('#dlgMending').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_Mending').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.Normal);
            $('#fmMending').form('clear');
            $('#fmMending input[name=roomId]').prev().focus();//设置焦点
            $('#cbRoomId_Mending').combobox('setValue', '');
        }

        function setNormal(roomId) {
            msgTitle = "房间可用";
            action = actionType.setNormal;
            actionUrl = "/room/setMending";
            $('#dlgMending').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_Mending').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.IsMending);
            $('#fmMending').form('clear');
            $('#fmMending input[name=roomId]').prev().focus();//设置焦点
            $('#cbRoomId_Mending').combobox('setValue', '');
            if (roomId != undefined) {
                $('#cbRoomId_Mending').combobox('setValue', roomId);
            }
        }
        function reviseCheckin() {
            msgTitle = "修改入住";
            action = actionType.reviseCheckin;
            actionUrl = "/room/reviseCheckin";
            $('#dlgCheckIn').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_CheckIn').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.CheckedIn);
            $('#fmCheckIn').form('clear');
            $('#fmCheckIn input[name=roomId]').prev().focus();//设置焦点
            $('#cbRoomId_CheckIn').combobox('setValue', '');
            $('#btnCheckinSubmit').linkbutton('enable');
        }
        function openPrintCheckin() {
            msgTitle = "打印入住";
            action = actionType.openPrintCheckin;
            actionUrl = "";
            $('#dlgCheckIn').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_CheckIn').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.CheckedIn);
            $('#fmCheckIn').form('clear');
            $('#fmCheckIn input[name=roomId]').prev().focus();//设置焦点
            $('#cbRoomId_CheckIn').combobox('setValue', '');
            $('#btnCheckinSubmit').linkbutton('disable');
        }
        function cancelCheckin() {
            msgTitle = "取消入住";
            action = actionType.cancelCheckin;
            actionUrl = "/room/cancelCheckin";
            $('#dlgMending').dialog('open').dialog('setTitle', msgTitle);
            $('#cbRoomId_Mending').combobox('reload', '/room/roomStatusOption?roomstatusid=' + roomStatusType.CheckedIn);
            $('#fmMending').form('clear');
            $('#fmMending input[name=roomId]').prev().focus();//设置焦点
            $('#cbRoomId_Mending').combobox('setValue', '');
        }
        function save() {
            var data = "";
            var confirmMsg = '确实要提交吗?'
            if (action == actionType.checkin || action == actionType.reviseCheckin) {
                if (!$('#fmCheckIn').form('enableValidation').form('validate')) {
                    return;
                }
                if ($('#cbRoomId_CheckIn').combobox('getValue') == '') {
                    $.messager.alert(msgTitle, '请选择房间！', 'error');
                    return;
                }
                data = $('#fmCheckIn').serialize();
            } else if (action == actionType.checkout) {
                if (!$('#fmCheckOut').form('enableValidation').form('validate')) {
                    return;
                }
                if ($('#cbRoomId_CheckOut').combobox('getValue') == '') {
                    $.messager.alert(msgTitle, '请选择房间！', 'error');
                    return;
                }
                var roomTotalFee = $('#txtroomTotalFee_Checkout').textbox('getValue');
                var deposit = $('#txtDeposit_Checkout').textbox('getValue');
                var consumeFee = $('#txtConsumeFee_Checkout').textbox('getValue');
                var totalFee = Number(roomTotalFee) + Number(consumeFee);
                confirmMsg = '累计(房费+消费)：' + totalFee + ', 还需要支付：' + (totalFee - deposit) + '<br/>';
                data = $('#fmCheckOut').serialize();
            }
            else {
                if ($('#cbRoomId_Mending').combobox('getValue') == '') {
                    $.messager.alert(msgTitle, '请选择房间！', 'error');
                    return;
                }
                var roomId = $('#cbRoomId_Mending').combobox('getValue');
                var isMending = 1;
                if (action == actionType.setNormal) {
                    isMending = 0;
                }
                data = 'roomId=' + roomId + '&ismending=' + isMending;
            }
            $.messager.confirm('Confirm', confirmMsg, function (r) {
                if (r) {
                    $.post(actionUrl,
                            data,
                            function (data) {
                                var msg = '';
                                if (data.msg.length != 0) {
                                    $.each(data.msg, function () {
                                        msg = data.msg + msg + '<br/>';
                                    });
                                    $.messager.alert(msgTitle, msg, 'error');
                                }
                                else {
                                    $.messager.alert(msgTitle, '提交成功!', 'info', function () { location.reload(); });
                                }
                            });
                }
            })
        }
    </script>
}